import {createRouter, createWebHistory} from 'vue-router';

const router = createRouter({
    // history: createWebHashHistory(),  // hash模式，
    history: createWebHistory(),  //h5模式createWebHistory
    routes: [
        {
            path: "",
            name: "redirect",
            redirect: "/index"
        },
        // {
        //     path: '/login',
        //     component: () => import('@/views/Login.vue'),
        //     meta: {
        //         title: '登录',
        //     }
        // },
        {
            path: '/',
            name: 'Home',
            component: () => import('@/views/Home.vue'),
            children: [
                {
                    path: 'index',
                    name: 'index',
                    component: () => import('@/views/Index.vue'),
                    meta: {
                        title: '首页',
                    },
                },
                {
                    path: 'project',
                    name: 'project',
                    component: () => import('@/views/Project.vue'),
                    meta: {
                        title: '项目管理',
                    },
                },
                {
                    path: 'service',
                    name: 'service',
                    component: () => import('@/views/Service.vue'),
                    meta: {
                        title: '服务管理',
                    },
                },
                {
                    path: 'branch',
                    name: 'branch',
                    component: () => import('@/views/Branch.vue'),
                    meta: {
                        title: '分支管理',
                    },
                },
                {
                    path: 'customer',
                    name: 'customer',
                    component: () => import('@/views/Customer.vue'),
                    meta: {
                        title: '客户管理',
                    },
                },
                {
                    path: 'worker',
                    name: 'worker',
                    component: () => import('@/views/Worker.vue'),
                    meta: {
                        title: '运维人员',
                    },
                },
                {
                    path: 'update',
                    name: 'update',
                    component: () => import('@/views/recode/UpdateRecode.vue'),
                    meta: {
                        title: '更新记录',
                    },
                },
                {
                    path: 'deploy',
                    name: 'deploy',
                    component: () => import('@/views/DeployRecode.vue'),
                    meta: {
                        title: '部署记录',
                    },
                }
            //    , {
            //         path: 'demo',
            //         name: 'demo',
            //         component: () => import('@/views/Demo.vue'),
            //         meta: {
            //             title: '演示页面',
            //             location: ['示例页', '演示页面'],
            //         },
            //     }
                // ,{
                //     path: 'tables',
                //     name: 'tables',
                //     component: () => import('@/views/Tables.vue'),
                //     meta: {
                //         title: '演示表格',
                //         location: ['示例页', '演示表格'],
                //     },
                // }
            ]
        }
        // ,{
        //     path: '/test',
        //     component: () => import('@/views/Test.vue'),
        //     meta: {
        //         title: '测试',
        //     }
        // }
    ]
})
// 路由导航守卫
router.beforeEach((to, from, next) => {
    document.title = to.meta.title
    next()
})
export default router;
